package com.nancy.java_design.iterator.demo1;

import java.util.ArrayList;
import java.util.List;

public class StudentIteratorImpl implements StudentIterator {
    List<Student> students = new ArrayList<Student>();

    private int position = 0;

    public StudentIteratorImpl(List<Student> students) {
        this.students = students;
    }

    @Override
    public boolean hasNext() {
        if (position < students.size()) {
            return true;
        }
        return false;
    }

    @Override
    public Student next() {
        Student student = students.get(position);
        position++;
        return student;
    }
}
